import component from "../../../common/component";
import BookBtn from "@/components/BookBtn";
import { Button  } from "antd";



class booked extends component {
    getColumns(): null {
        return [
            {
                title: '实验名称',
                dataIndex: 'tiliteName',
                key: 'tiliteName',
                width: 150,  
            },
            {
                title: '实验地点',
                dataIndex: 'location',
                key: 'location',
                width: 150,  
            },
            {
                title: '发布时间',
                dataIndex: 'releaseTime',
                key: 'releaseTime',
                width: 150,  
                sorter: (a, b) => {
                    // 将日期转成毫秒
                      const t1 = new Date(a.releaseTime).getTime();
                      const t2 = new Date(b.releaseTime).getTime();
                      return t1- t2
                    },
                    sortDirections: ['descend', 'ascend'],
                    defaultSortOrder: 'descend'
            },
            {
                title: '人数下限',
                dataIndex: 'peopleMin',
                key: 'peopleMin',
                width: 150,  
            },
            {
                title: '人数上限',
                dataIndex: 'peopleMax',
                key: 'peopleMax',
                width: 150,  
            },
            {
                title: '已预约人数',
                dataIndex: 'people',
                key: 'people',
                width: 150,  
            },
            {
                title: '实验开始时间',
                dataIndex: 'stime',
                key: 'stime',
                width: 150,  
            },
            {
                title: '实验结束时间',
                dataIndex: 'etime',
                key: 'etime',
                width: 150,  
            },
           
            {
                title: '操作',
                dataIndex: 'operation',
                fixed: 'right',
                width: 150,  
                render: (_, record) => {
                    if (record.enable == 0) {
                        return <BookBtn record={record} book={this.book} />
                    }
                    else{ 
                        return<Button disabled size={'small'}>实验已人数已满</Button>
                    } 
                },
            }
        ];
    }
}

export default booked;
